<?php
function formaterTableau ($req)
{
  if(count($req) != 0){
  $key = array_keys($req[0]);
  echo "<table border='1'><tr>";
  foreach($key as $k) {
    echo "<th> $k </th>";
  }
  echo "</tr>";
  foreach($req as $elt) {
    echo "<tr>";
    foreach($elt as $elt2) {
      echo "<td> $elt2 </td>";  
    }
    echo "</tr>";
  }
  echo "</table>";
  }
  else
    {
      echo "Table vide";
    }
}

function fabriqueMenu ($request,$bool){ // bool indique que la valeur doit obligatoirement etre renseignée
  if(count($request) != 0){
  $key = array_keys($request[0]);
  echo "<label for='".$key[0]."'>".$key[0]."</label><br/>
    <select name='".$key[0]."' id='".$key[0]."'>";
  if ($bool == 0){  
    echo "<option value='NULL'>NULL</option>"; 
  }  
  foreach($request as $elt){
    echo "<option value='".$elt[$key[0]]."'>".$elt[$key[0]]." (".$elt[$key[1]].")</option>";
  }
  echo  "</select>";
  }
}
?>
